<?php
$config = Vnf::getConfigs('conf');
$shoponline = @$config->shoponline;
?>
                                <div id="lastestproduct">
                                    <div class="blockcms">
                                        <div class="blocktitle">
                                            <h3>
                            <?php
                            $allItems = $this->allItems;
                            $currentPage = $this->currentPage;

                            if ($currentPage) {
                                // check exists parent
                                if ($currentPage['all_parent']) {
                                    $allParent = explode(',', $currentPage['all_parent']);
                                    if (isset($allParent[0])) {
                                        $allCategory = $this->allCategory;
                                        foreach($allParent as $parentID):
                                            $parent = $allCategory[$parentID];
                                            // check to ignore root
                                            if ($parent['left'] != 1) {
                                            ?>
                                                <a href="<?php echo BASE_PATH . '/' . CURR_APP ?>?pid=<?php echo $parent['category_id']?>" style="font-weight:bold;"><?php echo $parent['admin_title'];?></a> &raquo;
                                            <?php
                                            }
                                        endforeach;
                                    }
                                    echo "<span style=''>" . $currentPage['admin_title'] . "</span>";
                                }
                            }
                            ?>
                                            </h3>
                                        </div>
                                    <div class="blockcontent">
            <table cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="centerleft"></td>
                    <!--td class="centercontent" style="background:#a7d0f0;"-->
                    <td class="centercontent">
<?php
                $template = $this->template;
                if (!$template) {
?>
                                            <table width="100%" class="listitem" cellspacing="0" cellpadding="0">
                                                <tr>
                            <?php
                                $allItems = $this->allItems;
                                $currentPage = $this->currentPage;
                            ?>
                            <?php
                            if (isset($allItems[0])) {
                                $i = 0;
                                $itemPerRow = 4;
                                $widthPercent = 100/$itemPerRow;
                                foreach($allItems as $item):
                                    if ( ($i++ % $itemPerRow == 0) && ($i != 1)) {
                                ?>
                                    </tr>
                                    <tr>
                                <?php
                                    }
                                ?>
                                                    <td width="<?php echo $widthPercent?>%">
                                                        <div>
                                                            <a href="<?php echo BASE_URL ?>/index/index/detail?pid=<?php echo $item->category_id; ?>&id=<?php echo $item->item_id; ?>"><?php echo $item->item_title; ?></a>
                                                        </div>
                                                        <?php
                                                        if ($item->item_image) {
                                                        $path = pathinfo($item->item_image, PATHINFO_DIRNAME);
                                                        $fileName = pathinfo($item->item_image, PATHINFO_BASENAME);
                                                        ?>
                                                        <div>
                                                            <img src="<?=ImageUtil::getImage($path,$fileName,129, 129, 80, true)?>" class="border"></img>
                                                        </div>
                                                        <?php
                                                        }
                                                        ?>
                                                        <div>
                                                        <?php echo $item->item_price; ?> €
                                                        </div>
                                                    <?php
                                                    if ($shoponline) {
                                                    ?>
                                                        <div style="padding-top:10px">
                                                            <div style="color:red;cursor:pointer;padding:5px 0px" onclick="javascript:addToCart(<?php echo $item->item_id;?>)"><b>BUY NOW</b></div>
                                                        </div>
                                                    <?php
                                                    }
                                                    ?>
                                                    </td>
                                <?php
                                endforeach;
                            } // if items
                            ?>
                                                </tr>
                                            </table>
  <?php
                } // if template
                else {
                    include($template);
                }
?>                    </td>
                    <td class="centerright"></td>
                </tr>
            </table>
        </div>
        
    </div>
